import axios from '@/libs/api.request'
import config from '@/config'

export const getTaskTable = async (playload) => {
  const resp = await axios.request({
    url: config.apiUrl,
    params: {
      module: 'TaskService.view',
      ...playload
    },
    method: 'get'
  })
  return resp
}

export const editTaskListRecord = async (playload) => {
  let module_name = 'TaskService.add'
  if (playload.id && playload.id !== '') {
    module_name = 'TaskService.update'
  }
  const data = {
    module: module_name,
    ...playload
  }
  const resp = await axios.request({
    url: config.postUrl,
    data,
    method: 'post'
  })
  return resp
}

export const getPgoodsTable = async (playload) => {
  const resp = await axios.request({
    url: config.apiUrl,
    params: {
      module: 'GroupService.viewGoods',
      ...playload
    },
    method: 'get'
  })
  return resp
}

export const editPgoodsRecord = async (playload) => {
  let module_name = 'GroupService.addGood'
  if (playload.id && playload.id !== '') {
    module_name = 'GroupService.updateGoods'
  }
  const data = {
    module: module_name,
    ...playload
  }
  const resp = await axios.request({
    url: config.postUrl,
    data,
    method: 'post'
  })
  return resp
}

export const getUpGoodsTable = async (playload) => {
  const resp = await axios.request({
    url: config.apiUrl,
    params: {
      module: 'GroupService.orderList',
      ...playload
    },
    method: 'get'
  })
  return resp
}

export const getUpGoodsInfoTable = async (playload) => {
  const resp = await axios.request({
    url: config.apiUrl,
    params: {
      module: 'GroupService.orderInfo',
      ...playload
    },
    method: 'get'
  })
  return resp
}

export const editUpGoodsRecord = async (playload) => {
  const data = {
    module: 'GroupService.upState',
    ...playload
  }
  const resp = await axios.request({
    url: config.postUrl,
    data,
    method: 'post'
  })
  return resp
}

export const getConfigTask = async (payload) => {
  const resp = await axios.request({
    url: config.apiUrl,
    params: {
      module: 'AdminService.taskList',
      ...payload
    },
    method: 'get'
  })
  return resp
}

export const changeTaskData = async (payload) => {
  const data = {
    module: 'AdminService.importData',
    ...payload
  }
  const resp = await axios.request({
    url: config.postUrl,
    data,
    method: 'post'
  })
  return resp
}
